package com.up.upzl.biz.service.impl;

import java.util.List;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

import com.google.common.collect.Lists;
import com.up.upzl.biz.service.UserService;

@Service
public class CustomerUserServiceImpl implements UserDetailsService{

	@Autowired
	UserService userService;
	@Override
	public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
		com.up.upzl.biz.domain.User user=userService.findByAccount(username);
		String password=user.getPassword();
		//帐号是否启用
		boolean enabled=true;
		//帐号是否不过期
		boolean accountNonExpired=true;
		//帐号是否不过期
		boolean credentialsNonExpired=true;
		//帐号是否不锁定
		boolean accountNonLocked=true;
		List<GrantedAuthority> authorities=Lists.newArrayList();
		return new User(username, password, enabled, accountNonExpired, credentialsNonExpired, accountNonLocked, authorities);
	}

}
